import * as types from '../mutation-types'
import {_get, _post} from '@/api/index'


//定义变量
const state = {
  lists: [],
  banner: [],
};

//变量改变方法
const getters = {
  lists: state => state.lists,
  banner: state => state.banner
};

//获取变量请求
const actions = {
  getData({commit}) {
    _get({url: '/index/index'}).then((res) => {
      let data = res.data;
      commit('getLists', data.lists.data)
      commit('getBanner', data.slides)
    })
  }
}

//变量处理业务逻辑层
const mutations = {
  getLists(state, list) {
    return state.lists = list
  },
  getBanner(state, banner) {
    return state.banner = banner;
  }
}

export default {
  getters,
  actions,
  state,
  mutations
}
